<%@language=VBScript%>
<!--#include file="..\CheckSession.inc"-->
<!--#include file="..\jvfunction.inc"-->
<!--#include file="Nhap_VTdi\NhapNhanh_DVXL.inc"-->
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title></title>
</HEAD>
<%
	bLoaiVT=request("bLoaiVT")
	Dim Msg
	bComm=request("bComm")
	bID=Request("TxtID")
	Select Case bComm
		Case "okadd"
			bNgayden=trim(request("TxtNgayden"))
			bNgayden=SaveDate(bNgayden)
			bSoden=trim(request("TxtSoden"))
			bNoigui=trim(request("TxtNoigui"))
			bSokyhieu=trim(request("TxtSokyhieu"))
			bNgayky=trim(request("TxtNgayky"))
			bNgayky=SaveDate(bNgayky)
			bNguoinhan=trim(request("TxtNguoinhan"))
			bTrichyeu=trim(request("TxtTrichyeu"))
			bYkien=trim(request("TxtYkien"))
			bNguoiCN=Session("bMaCB")

			bTemp=bNoigui &", " & trim(request("TxtDonviXL"))
'			bTenDVXL=TenDonvixuly(bTemp)
			bTenDVXL=trim(request("TxtDonviXL"))
'			bDonviXL=Donvixuly(bTenDVXL)
			bDonviXL=Donvixuly(bTemp)
			bHanXL=trim(request("TxtHanXL"))
			if bHanXL="" then
				bHanXL="NULL"
			else
				bHanXL="'"+SaveDate(bHanXL)+"'"
			end if
			bNam=year(bNgayden)
			if KTSoden(bSoden,bNam,"okadd") then
			bID="TT"+cstr(bNam)+"_"+bSoden
			sSQL="INSERT INTO TOTRINH(ID,Ngayden,Soden,Noigui,Sokyhieu,NgayCV,Nguoinhan,Trichyeu,Ykienchidao,TenDVXL,DonviXL,HanXL,NguoiCN) Values ('" _
				& Modistring(bID) _
				&"','"& bNgayden _
				&"','"& Modistring(bSoden) _
				&"','"& Modistring(bNoigui) _
				&"','"& Modistring(bSokyhieu) _
				&"','"& bNgayky _
				&"','"& Modistring(bNguoinhan) _
				&"','"& Modistring(bTrichyeu) _
				&"','"& Modistring(bYkien) _
				&"','"& Modistring(bTenDVXL) _
				&"','"& Modistring(bDonviXL) _
				&"',"& bHanXL _
				&",'"& Modistring(bNguoiCN) &"')"
				Conn.Execute sSQL
				Msg="Nội dung cập nhật !"

			'Ghi nhan Ai da login thanh cong
				bHoten=Session("bHoten")
				bNgaygio=cstr(Date()) &" "& cstr(Time())
				bChucnang="Cap nhat to trinh - giao viec"
				bIDTailieu=bSoden
				bDongtac="Th&#234;m m&#7899;i"
				sSQL="insert into loguser(Tennguoisudung,ngaygio,chucnangdung,dongtac,IDTailieu,Trangthai) Values('"& bHoten _
					&"','"& bNgaygio &"','"& bChucnang &"','"& bDongtac &"','"& bIDTailieu &"',"& bTrangthai &")"
				Conn.Execute sSQL
				bComm="edit"
			else
				Msg="Số đến đã tồn tại !"
				bComm="add"
			end if
		Case "okedit"
			bNgayden=trim(request("TxtNgayden"))
			bNgayden=SaveDate(bNgayden)
			bSoden=trim(request("TxtSoden"))
			bNoigui=trim(request("TxtNoigui"))
			bSokyhieu=trim(request("TxtSokyhieu"))
			bNgayky=trim(request("TxtNgayky"))
			bNgayky=SaveDate(bNgayky)
			bNguoinhan=trim(request("TxtNguoinhan"))
			bTrichyeu=trim(request("TxtTrichyeu"))
			bYkien=trim(request("TxtYkien"))
			bTemp=bNoigui &", " & trim(request("TxtDonviXL"))
'			bTenDVXL=TenDonvixuly(bTemp)
			bTenDVXL=trim(request("TxtDonviXL"))
'			bDonviXL=Donvixuly(bTenDVXL)
			bDonviXL=Donvixuly(bTemp)

			bHanXL=trim(request("TxtHanXL"))
			if bHanXL="" then
				bHanXL="NULL"
			else
				bHanXL="'"+SaveDate(bHanXL)+"'"
			end if
			bNam=year(bNgayden)
			bNamcu=Request("bNamcu")
			bSodencu=Request("bSodencu")
			bIDcu=Request("bIDcu")
			if (trim(Cstr(bSoden))=trim(Cstr(bSodencu))) and (trim(Cstr(bNamcu))=trim(Cstr(bNam))) then
				sSQL="UPDATE TOTRINH Set Ngayden='" & bNgayden _
					&"',Noigui='" & Modistring(bNoigui) _
					&"',Sokyhieu='" & Modistring(bSokyhieu) _
					&"',NgayCV='" & bNgayky _
					&"',Nguoinhan='" & Modistring(bNguoinhan) _
					&"',Trichyeu='" & Modistring(bTrichyeu) _
					&"',Ykienchidao='" & Modistring(bYkien) _
					&"',TenDVXL='" & Modistring(bTenDVXL) _
					&"',DonviXL='" & Modistring(bDonviXL) _
					&"',HanXL=" & bHanXL _
					&" WHERE ID='" & bIDcu & "'"
				Conn.Execute sSQL
				bComm="edit"
			else
				if KTSoden(bSoden,bNam,"okedit") then
					bID="TT"+cstr(bNam)+"_"+bSoden
					sSQL="UPDATE TOTRINH Set ID='" & bID _
					&"',Ngayden='" & bNgayden _
					&"',Soden='" & Modistring(bSoden) _
					&"',Noigui='" & Modistring(bNoigui) _
					&"',Sokyhieu='" & Modistring(bSokyhieu) _
					&"',NgayCV='" & bNgayky _
					&"',Nguoinhan='" & Modistring(bNguoinhan) _
					&"',Trichyeu='" & Modistring(bTrichyeu) _
					&"',Ykienchidao='" & Modistring(bYkien) _
					&"',TenDVXL='" & Modistring(bTenDVXL) _
					&"',DonviXL='" & Modistring(bDonviXL) _
					&"',HanXL=" & bHanXL _
					&" WHERE ID='" & bIDcu & "'"
					Conn.Execute sSQL
					bComm="edit"
				else
					Msg="Số đến đã tồn tại !"
					bComm="edit"
				end if
			end if

			'Ghi nhan Ai da login thanh cong
			bHoten=Session("bHoten")
			bNgaygio=cstr(Date()) &" "& cstr(Time())
			bChucnang="Cap nhat to trinh - giao viec"
			bIDTailieu=bSoden
			bDongtac="Ghi nhan sua"
			bTrangthai=1
			sSQL="insert into loguser(Tennguoisudung,ngaygio,chucnangdung,dongtac,IDTailieu,Trangthai) Values('"& bHoten _
				&"','"& bNgaygio &"','"& bChucnang &"','"& bDongtac &"','"& bIDTailieu &"',"& bTrangthai &")"
			Conn.Execute sSQL
	End select
if bComm="edit" then	
	sSQL="Select * from Totrinh Where ID='" & bID & "'"
	Set Rec=Server.CreateObject("ADODB.Recordset")
	Rec.CursorType=3
	Rec.CacheSize=5
	Rec.Open sSQL,Conn
	if Rec.RecordCount>0 then
		bIDcu=Rec("ID")
		bNgayden=Rec("Ngayden")
		bSoden=Rec("Soden")
		bSodencu=Rec("Soden")
		bNoigui=Rec("Noigui")
		bSokyhieu=Rec("Sokyhieu")
		bNgayky=Rec("NgayCV")
		bNguoinhan=Rec("Nguoinhan")
		bTrichyeu=Rec("Trichyeu")
		bYkien=Rec("Ykienchidao")
		bTenDVXL=Rec("TenDVXL")
		bDonviXL=Rec("DonviXL")
		bHanXL=Rec("HanXL")
		bNguoiCN=Rec("NguoiCN")
		bNam=year(Rec("Ngayden"))
		bNamcu=bNam
	end if
end if
%>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function SetFocus(){
	if (!Noidung.TxtNoigui.disabled){
		Noidung.TxtNoigui.focus();
	}
}
function CmdAdd_Onclick(){
	window.Noidung.target="right";
	window.Noidung.action="frmTotrinh.asp?bComm=add";
	window.Noidung.submit();
}
function CmdOk_Onclick(){
if (KTNhap()){
	<%if bComm="add" then %>
		window.Noidung.target="right";
		window.Noidung.action="frmTotrinh.asp?bComm=okadd";
		window.Noidung.submit();
	<%end if%>
	<%if bComm="edit" then %>
		window.Noidung.target="right";
		window.Noidung.action="frmTotrinh.asp?bComm=okedit&bIDcu="+"<%=bIDcu%>"+ "&bNamcu="+"<%=bNamcu%>"+"&bSodencu="+"<%=bSodencu%>";
		window.Noidung.submit();
	<%end if%>
	}
}
function CmdFile_Onclick(){
	<%if bComm="add" then %>
		alert("Bạn cần phải ghi nhận văn bản trước");
		return false;
	<%end if%>
	<% if bComm="edit" then%>
		bID=Noidung.TxtID.value;
		window.Noidung.target="right";		window.Noidung.action="../editor/Attach.asp?bPost=ok&bMa="+bID+"&Filename="+bID+"&bLoaiVT=7&bNam="+"<%=bNam%>"+"&bNamcu="+"<%=bNamCu%>";
		window.Noidung.submit();
	<%end if%>
}
function CmdRight_Onclick(){
	window.Noidung.target="right";
	window.Noidung.action="duyetcanbodvxl.asp?bstepduyet=0&MaVT="+"<%=bID%>"+"&bMaLoaiVT=7";
	window.Noidung.submit();
}
function openaddDV(sObj) {
	tendonvixuly=Noidung.TxtDonviXL.value;
	popupWin = window.open('AddDonviXL.asp?btendonvixuly='+tendonvixuly+'&bID='+'<%=bID%>'+'&bmacanbo='+'<%=Session("bMaCB")%>','donvixuly_page','width=500,height=220,top=120,left=160').focus();
}
function CmdExit_Onclick(){
	window.Noidung.target="right";
	window.Noidung.action="frmdsTotrinh.asp?bComm=";
	window.Noidung.submit();
}
function KTNhap(){
	if (trim(Noidung.TxtNgayden.value)==""){
		alert("Cho biết ngày đến !");
		Noidung.TxtNgayden.focus();
		return false;
	}
	if (!isDate(Noidung.TxtNgayden.value)){
		alert("Ngày đến không hợp lệ !");
		Noidung.TxtNgayden.focus();
		return false;
	}
	if (trim(Noidung.TxtSoden.value)==""){
		alert("Cho biết số đến !");
		Noidung.TxtSoden.focus();
		return false;
	}
	if (!IsNumeric(Noidung.TxtSoden.value)){
		alert("Số đến không hợp lệ !");
		Noidung.TxtSoden.focus();
		return false;
	}
	if (trim(Noidung.TxtNoigui.value)==""){
		alert("Cho biết nơi gửi !");
		Noidung.TxtNoigui.focus();
		return false;
	}
	if (trim(Noidung.TxtSokyhieu.value)==""){
		alert("Cho biết số, ký hiệu !");
		Noidung.TxtSokyhieu.focus();
		return false;
	}
	if (trim(Noidung.TxtNgayky.value)==""){
		alert("Cho biết ngày ký !");
		Noidung.TxtNgayky.focus();
		return false;
	}
	if (!isDate(Noidung.TxtNgayky.value)){
		alert("Ngày ký không hợp lệ !");
		Noidung.TxtNgayky.focus();
		return false;
	}
	if (trim(Noidung.TxtNguoinhan.value)==""){
		alert("Cho biết nơi/người nhận !");
		Noidung.TxtNguoinhan.focus();
		return false;
	}
	if (trim(Noidung.TxtTrichyeu.value)==""){
		alert("Cho biết trích yếu nội dung");
		Noidung.TxtTrichyeu.focus();
		return false;
	}
	if (Noidung.TxtHanXL.value!=""){
		if (!isDate(Noidung.TxtHanXL.value)){
			alert("Hạn xử lý không hợp lệ !");
			Noidung.TxtHanXL.focus();
			return false;
		}
	}
	return true;
}

function TxtNgayden_onkeyup(str){
	var keycode
	keycode=window.event.keyCode
	if (isEdit(keycode,str)){
		Noidung.TxtNgayden.value=editdate(trim(str))
	}
}

function TxtNgayky_onkeyup(str){
	var keycode
	keycode=window.event.keyCode
	if (isEdit(keycode,str)){
		Noidung.TxtNgayky.value=editdate(trim(str))
	}
}
function TxtHanXL_onkeyup(str){
	var keycode
	keycode=window.event.keyCode
	if (isEdit(keycode,str)){
		Noidung.TxtHanXL.value=editdate(trim(str))
	}
}
function CmdNoigui_onclick(){
	str="";
	strtruoc=Noidung.TxtNoigui.value;
	if (strtruoc.length>0){
		strtruoc=strtruoc+", "
	}
	eval('ListRecordDV(str,escape(strtruoc),"Noidung.TxtNoigui.value",245,250,250,240)');
	return false;
}

function TxtNoigui_onkeydown(){
var keycode
keycode=window.event.keyCode;
str=Noidung.TxtNoigui.value;
strtruoc="";
	if (keycode==13){
		if (str==""){
			eval('ListRecordDV(str,escape(strtruoc),"Noidung.TxtNoigui.value",245,250,245,240)');
			return false;
		}else{
			intpc=str.lastIndexOf(",");
			strtruoc=str.substr(0,intpc+1);
			str=str.substr(intpc+1,str.length-intpc);
			str=trim(str);
			if (strtruoc.length>0){
				strtruoc+=" ";
			}
			if (CheckMaDV(str)==1){
				Noidung.TxtNoigui.value=strtruoc+FindOneMaDV(str);
				return false;
			}else{
				if (CheckMaDV(str)==0){
					if (CheckTenDV(str)==1){
						Noidung.TxtNoigui.value=strtruoc+FindOneTenDV(str);
						return false;
					}else{
						if (CheckTenDV(str)>1){
							eval('ListRecordDV(str,escape(strtruoc),"Noidung.TxtNoigui.value",245,250,245,240)');
							return false;
						}else{
							Noidung.TxtNoigui.value=strtruoc+str;
							return false;
						}
					}
				}else{
					eval('ListRecordDV(str,escape(strtruoc),"Noidung.TxtNoigui.value",245,250,245,240)');
					return false;
				}
			}
		}
	}
}

function TxtDonviXL_onkeydown(){
var keycode
keycode=window.event.keyCode;
str=Noidung.TxtDonviXL.value;
strtruoc="";
	if (keycode==13){
		if (str==""){
			eval('ListRecordDV(str,escape(strtruoc),"Noidung.TxtDonviXL.value",245,250,245,240)');
			return false;
		}else{
			intpc=str.lastIndexOf(",");
			strtruoc=str.substr(0,intpc+1);
			str=str.substr(intpc+1,str.length-intpc);
			str=trim(str);
			if (strtruoc.length>0){
				strtruoc+=" ";
			}
			if (CheckMaDV(str)==1){
				Noidung.TxtDonviXL.value=strtruoc+FindOneMaDV(str);
				return false;
			}else{
				if (CheckMaDV(str)==0){
					if (CheckTenDV(str)==1){
						Noidung.TxtDonviXL.value=strtruoc+FindOneTenDV(str);
						return false;
					}else{
						if (CheckTenDV(str)>1){
							eval('ListRecordDV(str,escape(strtruoc),"Noidung.TxtDonviXL.value",245,250,245,240)');
							return false;
						}else{
							Noidung.TxtDonviXL.value=strtruoc+str;
							return false;
						}
					}
				}else{
					eval('ListRecordDV(str,escape(strtruoc),"Noidung.TxtDonviXL.value",245,250,245,240)');
					return false;
				}
			}
		}
	}
}
//-->
</SCRIPT>
<Script language=VBScript runat=server>
Function KTSoden(bValueO,bValueY,loai)
	KTSoden=false
	if loai="okedit" then			
			sSQL="Select ID from Totrinh where Soden='"& Modistring(bValueO) &"' and year(Ngayden)="& bValueY
			set RecKT=server.CreateObject("ADODB.Recordset")
			RecKT.CursorType=3
			RecKT.CacheSize=5
			RecKT.Open sSQL,Conn
			if RecKT.RecordCount<=0 then
				KTSoden=true
			end if
			RecKT.Close
			set RecKT=nothing
	end if
	if loai="okadd" then
		sSQL="Select ID from Totrinh where Soden= '"& Modistring(bValueO) &"' and year(Ngayden)="& bValueY
		set RecKT=server.CreateObject("ADODB.Recordset")
		RecKT.CursorType=3
		RecKT.CacheSize=5
		RecKT.Open sSQL,Conn
		if RecKT.RecordCount<=0 then
			KTSoden=true
		end if
		RecKT.Close
		set RecKT=nothing
	end if
end function
' M/D/Y-> D/M/Y
Function FormatDate(vDate)
   If Not IsNull(vDate) Then
		vM = Right("0" & Month(vDate), 2)
		vD = Right("0" & Day(vDate), 2)
		vY = Right("19" & Year(vDate), 4)
		FormatDate = vD & "/" & vM & "/" & vY
   End If
End Function
Function SaveDate(vDate)
	dim bvitri1
	dim bvitri2
   vDate=trim(cstr(vDate))
   bvitri1=instr(1,vDate,"/")
   bMonth=left(vDate,bvitri1-1)
   bvitri2=instr(bvitri1+1,vDate,"/")
   Dim Temp
   Temp=right(vDate,len(vDate)-bvitri1)
   bDay=left(Temp,bvitri2-bvitri1-1)
   bYear=right(vDate,len(vDate)-bvitri2)
   SaveDate=bDay+"/"+bMonth+"/"+bYear
End Function

Function ModiString(mess_s)
	message = Replace("" & mess_s,"'", "''")
	ModiString=message
End function
'Tim Madonvi tuong ung neu chuoi nhap vao dung la Ten cua 1DV
Function Donvixuly(strTendonvixuly)
	check=true
	if strTendonvixuly="" then
		strdonvixuly=""
	else
		strdonvixuly="-"
	end if
	strdonvixulyloi=""
	intlong=len(strTendonvixuly)
	i=0
	i=instr(1,strTendonvixuly,",")
	j=1
	k=0
	l=0
	if i <=0 then
		c=0
		Set RecDV=server.CreateObject("ADODB.Recordset")
		RecDV.CursorType=3
		RecDV.CacheSize=5
		c=instr(1,strTendonvixuly,"LĐTC")
		if c=1 then
			CTendonvixuly="LĐTC"
		else
			CTendonvixuly=strTendonvixuly
		end if
		sSQL="select madonvi from donvi where tendonvi like '"& CTendonvixuly &"'"
		RecDV.Open sSQL,Conn
		if RecDV.Recordcount then
			strdonvixuly="-"+RecDV("madonvi")+"M-"
		else
			strdonvixulyloi=strTendonvixuly
		end if
		RecDV.close
		set RecDV=nothing
	else
		do while check
			c=0
			Set RecDV=server.CreateObject("ADODB.Recordset")
			RecDV.CursorType=3
			RecDV.CacheSize=5
			c=instr(1,mid(strTendonvixuly,j,i-j),"LĐTC")
			if c=1 then
				CTendonvixuly="LĐTC"
			else
				CTendonvixuly=mid(strTendonvixuly,j,i-j)
			end if
			sSQL="select madonvi from donvi where tendonvi like '"& CTendonvixuly &"'"
			RecDV.Open sSQL,Conn
			if RecDV.Recordcount then
				if l=0 then
					strdonvixuly=strdonvixuly+RecDV("madonvi")+"M-"
				else
					strdonvixuly=strdonvixuly+RecDV("madonvi")+"S-"
				end if
			else
				strdonvixulyloi=strdonvixulyloi+mid(strTendonvixuly,j,i-j)+","
			end if
			RecDV.close
			set RecDV=nothing
			k=instr(i+1,strTendonvixuly,",")
			j=i+2
			if k <=0 then
				c=0
				check=false
				Set RecDV=server.CreateObject("ADODB.Recordset")
				RecDV.CursorType=3
				RecDV.CacheSize=5
				c=instr(1,mid(strTendonvixuly,j,intlong-j+1),"LĐTC")
				if c=1 then
					CTendonvixuly="LĐTC"
				else
					CTendonvixuly=mid(strTendonvixuly,j,intlong-j+1)
				end if
				sSQL="select madonvi from donvi where tendonvi like '"& CTendonvixuly &"'"
				RecDV.Open sSQL,Conn
				if RecDV.Recordcount then
					strdonvixuly=strdonvixuly+RecDV("madonvi")+"S-"
				else
					strdonvixulyloi=strdonvixulyloi+mid(strTendonvixuly,j,intlong-j+1)+","
				end if
				RecDV.close
				set RecDV=nothing
			else
				check=true
			end if
			i=k
			l=l+1
		loop
	end if
	Donvixuly=strdonvixuly
End function
</Script>
<BODY bgcolor=#F8F9D9 topmargin="0" leftmargin="0" style="font-family:Times New Roman; font-size:12pt" onload="SetFocus()">
<%if Msg<>"" then%>
	<p align=center><font face="Times New Roman" size=3 color=red><%=Msg%></font></p>
<%end if%>
<FORM name="Noidung" Method="Post">
<Table width="100%" border="0" cellspacing="0" style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: solid;border-collapse:collapse; border-color:#C0C0C0" bordercolor="#111111" bgcolor="#BDD5D0">
	<Input type=hidden name='TxtID' value='<%=bID%>'>
	<tr bgcolor="#000080"><td width="100%" colspan="4" align="center" style="color: #FFFFFF;font-size:11pt"><B>TỜ TRÌNH - GIAO VIỆC</B></td></tr>
	<tr>
		<td width="18%" nowrap>&nbsp;Ngày đến</td>
		<td width="37%">
		<%if bComm="add" then%>
			<input type="text" name="TxtNgayden" value="<%= FormatDate(Date)%>" style="font-family: Arial; width:100%" maxlength="10" lang="ja" onkeyup="return TxtNgayden_onkeyup(this.value)" tabindex="1"></td>
		<%else%>
			<input type="text" name="TxtNgayden"  value="<%=FormatDate(bNgayden)%>" style="font-family: Arial; width:100%" maxlength="10" lang="ja" onkeyup="return TxtNgayden_onkeyup(this.value)" tabindex="1"></td>
		<%end if%>
		<td width="15%" align=center nowrap>Số đến</td>
		<td width="30%">
		<%if bComm="add" then%>
			<%				
				Set RecMax=Server.createObject("ADODB.Recordset")
				RecMax.CursorType=3
				RecMax.CacheSize=5
				sSQL="Select Soden from Totrinh where year(Ngayden)=year(getdate()) order by len(Soden),Soden"
				RecMax.Open sSQL,Conn
				if RecMax.recordcount then
					RecMax.MoveLast
					AutoSoden =cstr(cint(RecMax("Soden"))+1)
				else
					AutoSoden ="1"
				end if
				RecMax.close
				set RecMax=nothing
			%>
			<input type="text" name="TxtSoden" value='<%=AutoSoden%>' style="font-family: Arial; width:100%" maxlength="40" tabindex="2"></td>
		<%else%>
			<input type="text" name="TxtSoden" value="<%=bSoden%>" style="font-family: Arial; width:100%" maxlength="40" tabindex="2"></td>
		<%end if%>
	</tr>
	<tr>
		<td width="18%" nowrap><input type=button onclick="javascript:CmdNoigui_onclick()" value="Nơi gửi" name=CmdNoigui style="font-family:Times New Roman; font-size:11pt;width:100%; background-color=#BDD5D0;height:23"></td>
		<td width="82%" colspan="3">
		<%if bComm="add" then%>
			<input type="text" name="TxtNoigui" style="font-family: Arial; width:100%" onkeydown="return TxtNoigui_onkeydown()" maxlength="350" tabindex="3"></td>
		<%else%>
			<input type="text" name="TxtNoigui" value="<%=bNoigui%>" style="font-family: Arial; width:100%" onkeydown="return TxtNoigui_onkeydown()" maxlength="350" tabindex="3"></td>
		<%end if%>
	</tr>
	<tr>
		<td width="18%" nowrap>&nbsp;Số, ký hiệu</td>
		<td width="37%">
		<%if bComm="add" then%>
			<input type="text" name="TxtSokyhieu" style="font-family: Arial; width:100%" maxlength="100" tabindex="4"></td>
		<%else%>
			<input type="text" name="TxtSokyhieu" value="<%=bSokyhieu%>" style="font-family: Arial; width:100%" maxlength="100" tabindex="4"></td>
		<%end if%>
		<td width="15%" align="center" nowrap>Ngày ký</td>
		<td width="30%">
		<%if bComm="add" then%>
			<input type="text" name="TxtNgayky" style="font-family: Arial; width:100%" maxlength="10" lang="ja" onkeyup="return TxtNgayky_onkeyup(this.value)" tabindex="5"></td>
		<%else%>
			<input type="text" name="TxtNgayky" value="<%=FormatDate(bNgayky)%>" style="font-family: Arial; width:100%" maxlength="10" lang="ja" onkeyup="return TxtNgayky_onkeyup(this.value)" tabindex="5"></td>
		<%end if%>
	</tr>
	<tr>
		<td width="18%" nowrap>&nbsp;Nơi, người nhận</td>
		<td width="82%" colspan="3">
		<%if bComm="add" then%>
			<input type="text" name="TxtNguoinhan" style="font-family: Arial; width:100%" maxlength="150" tabindex="6"></td>
		<%else%>
			<input type="text" name="TxtNguoinhan" value="<%=bNguoinhan%>" style="font-family: Arial; width:100%" maxlength="150" tabindex="6"></td>
		<%end if%>
	</tr>
	<tr>
		<td width="18%" nowrap>&nbsp;Trích yếu ND</td>
		<td width="82%" colspan="3">
		<%if bComm="add" then%>
			<textarea name="TxtTrichyeu" style="font-family: Arial; width:100%" rows="4" maxlength="2500" tabindex="7"></textarea></td>
		<%else%>
			<textarea name="TxtTrichyeu" style="font-family: Arial; width:100%" rows="4" maxlength="2500" tabindex="7"><%=bTrichyeu%></textarea></td>
		<%end if%>
	</tr>
	<tr>
		<td width="18%" nowrap>&nbsp;Ý kiến chỉ đạo</td>
		<td width="82%" colspan="3">
		<%if bComm="add" then%>
			<% if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),3)="1" or Session("IsAdmin")then%>
				<textarea name="TxtYkien" style="font-family: Arial; width:100%"  rows="3" maxlength="1800" tabindex="8"></textarea></td>
			<%else%>
				<textarea name="TxtYkien" style="font-family: Arial; width:100%"  rows="3" maxlength="1800" tabindex="8" disabled></textarea></td>
			<%end if%>
		<%else%>
			<% if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),3)="1" or Session("IsAdmin")then%>
				<textarea name="TxtYkien" style="font-family: Arial; width:100%"  rows="3" maxlength="1800" tabindex="8"><%=bYkien%></textarea></td>
			<%else%>
				<textarea name="TxtYkien" style="font-family: Arial; width:100%"  rows="3" maxlength="1800" tabindex="8" disabled><%=bYkien%></textarea></td>
			<%end if%>
		<%end if%>
	</tr>	
	<tr>
		<td width="18%" nowrap>
			<% if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),3)="1" or Session("IsAdmin")then%>
				<Button name=CmdDonviXL onclick="javaScript:openaddDV()" style='font-family: Arial;width: 100%; background-color:#BDD5D0; height:23'><p>Đơ<u>n</u> vị xử lý</p></Button></td>
			<%else%>
				<Button name=CmdDonviXL onclick="javaScript:openaddDV()" style='font-family: Arial;width: 100%; background-color:#BDD5D0; height:23' disabled><p>Đơ<u>n</u> vị xử lý</p></Button></td>
			<%end if%>
		<td width="37%">
		<%if bComm="add" then%>
			<% if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),3)="1" or Session("IsAdmin") then %>
				<input type="text" name="TxtDonviXL" style="font-family: Arial; width:100%" onkeydown="return TxtDonviXL_onkeydown()" maxlength="350" tabindex="9"></td>
			<%else%>
				<input type="text" name="TxtDonviXL" style="font-family: Arial; width:100%" onkeydown="return TxtDonviXL_onkeydown()" maxlength="350" tabindex="9" disabled></td>
			<%end if%>
		<%else%>
			<% if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),3)="1" or Session("IsAdmin") then %>
				<input type="text" name="TxtDonviXL" value="<%=bTenDVXL%>" style="font-family: Arial; width:100%" onkeydown="return TxtDonviXL_onkeydown()" maxlength="350" tabindex="9"></td>
			<%else%>
				<input type="text" name="TxtDonviXL" value="<%=bTenDVXL%>" style="font-family: Arial; width:100%" onkeydown="return TxtDonviXL_onkeydown()" maxlength="350" tabindex="9" disabled></td>
			<%end if%>
		<%end if%>
		<td width="15%" align="center">Hạn xử lý</td>
		<td width="30%">
		<%if bComm="add" then%>
			<% if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),3)="1" or Session("IsAdmin") then %>
				<input type="text" name="TxtHanXL" style="font-family: Arial; width:100%" maxlength="10" lang="ja" onkeyup="return TxtHanXL_onkeyup(this.value)" tabindex="10"></td>
			<%else%>
				<input type="text" name="TxtHanXL" style="font-family: Arial; width:100%" maxlength="10" lang="ja" onkeyup="return TxtHanXL_onkeyup(this.value)" tabindex="10" disabled></td>
			<%end if%>
		<%else%>
			<% if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),3)="1" or Session("IsAdmin") then %>
				<input type="text" name="TxtHanXL" value="<%=FormatDate(bHanXL)%>" style="font-family: Arial; width:100%" maxlength="10" lang="ja" onkeyup="return TxtHanXL_onkeyup(this.value)" tabindex="10"></td>
			<%else%>
				<input type="text" name="TxtHanXL" value="<%=FormatDate(bHanXL)%>" style="font-family: Arial; width:100%" maxlength="10" lang="ja" onkeyup="return TxtHanXL_onkeyup(this.value)" tabindex="10" disabled></td>
			<%end if%>
		<%end if%>
	</tr>	
</Table>
<Table width="100%" border="0" cellspacing="0" style="BORDER-BOTTOM-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: none;border-collapse:collapse; border-color:#C0C0C0" bordercolor="#111111" bgcolor="#BDD5D0">
<tr>
	<td width="20%"><button name="CmdAdd" lang="ja" onClick="return CmdAdd_Onclick()" accesskey="T" style="font-family: Arial; width:100%"><u>T</u>hêm mới</button></td>
<%if bComm="edit" then%>
	<td width="20%"><button name="CmdFile" lang="ja" onClick="return CmdFile_Onclick()" accesskey="k" style="font-family: Arial; width:100%">Gắn <u>k</u>èm tệp tin</button></td>
<%else%>
	<td width="20%"><button name="CmdFile" lang="ja" onClick="return CmdFile_Onclick()" accesskey="k" style="font-family: Arial; width:100%" disabled>Gắn <u>k</u>èm tệp tin</button></td>
<%end if%>
<% if (Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),4)="1" or Session("IsAdmin")) and (bComm="edit") then%>
	<td width="20%"><button name="CmdRight" lang="ja" onClick="return CmdRight_Onclick()" accesskey="P" style="font-family: Arial; width:100%"><u>P</u>hân 
        quyền</button></td>
<%else%>
	<td width="20%"><button name="CmdRight" lang="ja" onClick="return CmdRight_Onclick()" accesskey="P" style="font-family: Arial; width:100%" disabled><u>P</u>hân 
        quyền</button></td>
<%end if%>
	<td width="20%"><button name="CmdOK" lang="ja" onClick="return CmdOk_Onclick()" accesskey="G" style="font-family: Arial; width:100%" tabindex="11"><u>G</u>hi nhận</button></td>
	<td width="20%"><button name="CmdExit" lang="ja" onClick="return CmdExit_Onclick()" accesskey="y" style="font-family: Arial; width:100%">Qua<u>y</u> lại</button></td>
</tr>
</Table>
</FORM>
</BODY>
<%
	Conn.Close
	set Conn=nothing
%>
</HTML>